from mcp.server.fastmcp import FastMCP

# 创建MCP服务
mcp = FastMCP("Calculator Service")

@mcp.tool()
def add(a: float, b: float) -> float:
    """Add two numbers"""
    return a + b

@mcp.tool()
def subtract(a: float, b: float) -> float:
    """Subtract second number from first"""
    return a - b

@mcp.tool()
def multiply(a: float, b: float) -> float:
    """Multiply two numbers"""
    return a * b

@mcp.tool()
def divide(a: float, b: float) -> float:
        """Divide first number by second, raises ValueError if division by zero"""
        if b == 0:
            raise ValueError("Division by zero is not allowed")
        return a / b

if __name__ == "__main__":
    mcp.run(transport="stdio")